<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" %>
<%@ page import="icom.acm.bean.T_USERSET" %>    
<%@ page import="icom.acm.util.StaticData" %>

<script type="text/javascript">
<!--
$(function(){
	var fm_test_op = {
		url: 'UserSet_test',	// 
		dataType: 'text',
		beforeSubmit: function(formData, jqForm, options){
			//alert(formData.form.U_ID);
			var msg = $('#id1').val();
			if (msg==''){
				Pub_alert_before('alert', '警告', '写点什么吧.', $('#fm_test'));
				return false;
			}
			return true;
		},
		success: function(data, statusText){		
			data = eval('('+data+')');			
			if (data.success){
				Pub_alert('alert alert-success', '成功', data.msg, $('#fm_test'));
			} else {
				Pub_alert('alert alert-error', '错误', data.msg, $('#fm_test'));
			}			
		}
	};	
	$('#fm_test').ajaxForm(fm_test_op);
	

// gangcixiae
	var url = 'UserSet_getUserSetInfo';
	$.post(url,function(data){
		data = eval('('+data+')');
		if (data.success){
			var objs = data.children;
			var html='';			
			for (var i=0;i<objs.length;i++){
				if(objs[i].US_PID == -1)				
				html += GetFatherDiv(objs[i], objs);
			}
			$('#sectionLinks').append(html);
			// 查看代码
			//var   meizz   =   window.open( " "); 
			//meizz.document.write(html); 
			//meizz.document.close();
			//open().document.body.innerText   =   document.documentElement.outerHTML;
			// 查看完毕
		} else {
			alert(data.msg);
		}
	});
});

function GetFatherDiv(father, children){
	var html = '<div class="accordion-group"><div class="accordion-heading"><a class="accordion-toggle" data-toggle="collapse" data-parent="#sectionLinks" href="#collapse'+ father.US_ID +'" style= "font-weight:bold">'+father.US_NAME +'</a></div><div id="collapse'+ father.US_ID +'" class="accordion-body collapse in">';
	for (var i=0;i<children.length;i++){
		if(children[i].US_PID == father.US_ID)
			html += GetChildDiv(children[i]);
	}
	html += '</div></div>';
	return html;
}
function GetChildDiv(obj){
	var html = '<div class="accordion-inner"><a href=u/'+ obj.US_URL +' target="mainFrame">'+ obj.US_NAME +'</a></div>';
	return html;
}


function clk(){
	$('#fm_test').submit();
}
//-->
</script>

<div class="accordion" id="sectionLinks">
<form id="fm_test">
		<input type="text" id="id1"  name="form.a"/> 
		<a class="btn" onclick="clk()">提交</a>
	</form>
</div>